<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加记事分类</title>
    {% include "./header.html" %}
</head>

<body>
    <form role="form" method="post">
        <div class="box-body">
            <div class="form-group">
                <label for="name">分类名称</label>
                <input class="form-control" id="name" name="name" placeholder="请输入分类名称">
            </div>
            <div class="form-group">
                <label for="remark">备注</label>
                <input class="form-control" id="remark" name="remark" placeholder="请输入备注">
            </div>
        </div>
        <div class="box-footer">
            <button type="button" class="btn btn-primary button">确认提交</button>
        </div>
    </form>
    {% include "./footer.html" %}
</body>
<script>
    $(function () {
        $(".button").click(function () {
            var name=$("#name").val();
            var remark=$("#remark").val();
            $.ajax({
                type: 'post',
                url: 'http://127.0.0.1:8360/category/save',
                data:{"name":name,"remark":remark},
                success: function (data) {
                    if(data.succ){
                        alert("添加成功");
                        window.location.href="http://127.0.0.1:8360/category/index"
                    }else{
                        alert("添加失败");
                    }
                }
            });

        });

    })

</script>

</html>